#include<iostream>
#include<vector>
#include<unordered_map>
using namespace std;

class Solution {
public:
	bool containsNearbyDuplicate(vector<int>& nums, int k) {
		unordered_map<int, int> dictionary;
		int length = nums.size();
		for (int i = 0; i < length; i++) {
			int num = nums[i];
			if (dictionary.count(num) && i - dictionary[num] <= k) {
				return true;
			}
			dictionary[num] = i;
		}
		return false;
	}

};

void main() {

}